using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace BardsTaleViewer {
  public class Anim_Atari : IAnim {
    public List<IAnimFrame> _frames;

    public Anim_Atari (byte [] dump, ref int offset, int pictureIndex, int animIndex) {
      _frames = new List<IAnimFrame> ();
      int frameIndex = 0;
      while (dump.ReadWord (offset) != 0xFFFF) {
        _frames.Add (new AnimFrame_Atari (dump, ref offset, pictureIndex, animIndex, frameIndex));
        frameIndex++;
      }
      offset += 2;
    }

    public void CreateBitmaps (Bitmap bitmap, object paletteBase, byte [] data) {
      Bitmap bitmapPrev = bitmap.Copy ();
      Graphics g = Graphics.FromImage (bitmapPrev);
      foreach (AnimFrame_Atari frame in _frames) {
        frame.CreateBitmap ((Palette) paletteBase, data);
        g.DrawImage (frame._bitmapDiff, 0, 0);
        //frame.CreateBitmaps (bitmap, paletteBase, data.Extract (0));
      }
    }

    public List<IAnimFrame> Frames {
      get {
        return (_frames);
      }
    }

    public Point PosXY {
      get {
        return (new Point (0, 0));
      }
    }

    public bool DelayBefore {
      get {
        return (true);
      }
    }
  }
}
